using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace ShuJuGj.Entity.OutData
{
    public class BaseOutData
    {
        private string retcode;

        public string Retcode
        {
            get { return retcode; }
            set { retcode = value; }
        }

        private string rettext;

        public string Rettext
        {
            get { return rettext; }
            set { rettext = value; }
        }

        private XmlNode dataNode;

        public XmlNode DataNode
        {
            get { return dataNode; }
            set { dataNode = value; }
        }

        public BaseOutData(string outXml)
        {
            outXml = outXml.Replace(" xmlns=\"http://www.neusoft.com/hit/rhin\"", "");
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(outXml);
            XmlNode retNode = xmlDoc.SelectSingleNode("//messages//business//returnmessage");
            if (retNode != null)
            {
                this.retcode = retNode["retcode"].InnerText;
                this.rettext = retNode["rettext"].InnerText;
                if (this.retcode == "1")
                {
                    this.dataNode = xmlDoc.SelectSingleNode("//messages//business//businessdata");
                }
            }
        }

        public string GetNodeData(string nodeTag)
        {
            if (dataNode != null)
            {
                return dataNode[nodeTag] == null ? "" : dataNode[nodeTag].InnerText;
            }
            else
            {
                return string.Empty;
            }
        }
    }
}